import oscP5.*; //<>//
import netP5.*;
import java.io.*;
import java.util.*;

/* map OSC controllers to user variables for sketches */
float oscX, oscY = 0.0;
float oscRot;

/* various screen activity switches, some only for controller */
boolean Activity;
boolean soundAct;
boolean keyAct;
boolean displayAct;
boolean oscAct;
boolean facetAct;
boolean ControlActivity;
int knownFacet=-1;

//! functional constants
float gm = 1.60;
float gr = 0.60;
PFont font;

void draw() {  
  if ((facetAct)||(seqAct)) { 
    Activity=true;
  } else {
    Activity=false;
  }
  if ((!androidMode)&&((displayAct)||(soundAct)||(keyAct)||(oscAct))) {
    ControlActivity=true;
  } else {
    ControlActivity=false;
  }
  if (Activity) {
    commonStage();
  }
}

void commonStage() {
  if (facetAct){
    F_ImgSeq f_imgseq = ImgSeqList.get(0);
    f_imgseq.drawFO();    
  }
  switch(knownFacet) {
  default:
    break;
  }
}

void InitFacetObjects() {
  //initialize facet objects, find indexes for addressing with OSC
  seqList = new IntList();
  seqList.clear();
  for (int i = 1;i< facets.length;i++) {
    //search by type
    if (facets[i][0].equals("seq")==true){
      ImgSeqList.add(new F_ImgSeq(i, facets[i][2], int(facets[i][3])));
      seqList.append(i);
      facets[i][1]=str(seqList.size());
    }    
  }
}

void commonSetup() {
  ImgSeqList = new ArrayList();
  //hint(ENABLE_STROKE_PURE)  // this code will make single line graphics nicer, but slower
  imageMode(CENTER);
  colorMode(HSB, 100);
  oscSetup();
  InitSeed();
  InitFacetObjects();
  textFont(createFont("sans-serif", 27));
}
